<?php

namespace Xrfg\Core\Trading\Spot\Models;

use Illuminate\Database\Eloquent\Model;
use Xrfg\Core\Trading\Account\Models\AccountLogHelper;
use Xrfg\Core\Trading\Account\Models\Coin;
use Xrfg\Core\User\Models\User;

/**
 * Xrfg\Core\Trading\Spot\Models\SpotAccount.
 *
 * @property int                                    $id        账户ID
 * @property int                                    $user_id   用户ID
 * @property int                                    $coin_id   币种ID
 * @property float|null                             $available 可用余额
 * @property float|null                             $disabled  冻结余额
 * @property \Xrfg\Core\Trading\Account\Models\Coin $coin
 * @property \Xrfg\Core\User\Models\User            $user
 *
 * @method static \Illuminate\Database\Eloquent\Builder|\Xrfg\Core\Trading\Spot\Models\SpotAccount newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\Xrfg\Core\Trading\Spot\Models\SpotAccount newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\Xrfg\Core\Trading\Spot\Models\SpotAccount query()
 * @method static \Illuminate\Database\Eloquent\Builder|\Xrfg\Core\Trading\Spot\Models\SpotAccount whereAvailable($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\Xrfg\Core\Trading\Spot\Models\SpotAccount whereCoinId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\Xrfg\Core\Trading\Spot\Models\SpotAccount whereDisabled($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\Xrfg\Core\Trading\Spot\Models\SpotAccount whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\Xrfg\Core\Trading\Spot\Models\SpotAccount whereUserId($value)
 * @mixin \Eloquent
 */
class SpotAccount extends Model
{
    use AccountLogHelper;

    public $timestamps = false;

    protected $fillable = ['coin_id', 'user_id'];

    protected $table = 'trading_spot_accounts';

    public function coin()
    {
        return $this->hasOne(Coin::class, 'id', 'coin_id');
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}
